package com.imarkket.Library;

import android.util.Log;

/**
 * Created by Sistemas on 23/05/2014.
 */
public class c_logging {
    public static final String TAG = "DEBUG";

    public static final int LOG_VERBOSE = 0;
    public static final int LOG_DEBUG = 1;
    public static final int LOG_INFO = 2;
    public static final int LOG_WARNING = 3;
    public static final int LOG_ERROR = 4;

    private static c_logging instance;
    private static boolean actif;

    public static c_logging getInstance() {
        if (null == instance)
            instance = new c_logging();
        return instance;
    }

    private c_logging() {
        c_logging.setActif(true);
    }

    public void log(Integer type, String mensaje) {
        /*
		 * Log.v(); // Verbose Log.d(); // Debug Log.i(); // Info Log.w(); // Warning Log.e(); // Error
		 */
        if (isActif()) {

            switch (type) {
                case LOG_VERBOSE:
                    Log.v(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
                    break;
                case LOG_DEBUG:
                    Log.d(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
                    break;
                case LOG_INFO:
                    Log.i(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
                    break;
                case LOG_WARNING:
                    Log.w(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
                    break;
                case LOG_ERROR:
                    Log.e(TAG, (new Exception().getStackTrace()[1].getClassName()) + "." + (new Exception().getStackTrace()[1].getMethodName()) + ": " + mensaje);
                    break;
            }
        }
    }

    public static boolean isActif() {
        return actif;
    }

    public static void setActif(boolean actif) {
        c_logging.actif = actif;
    }
}
